package com.lyn.pluginbazaar.utils;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPool {

    private static class ThreadPoolTypeClass {
        private static final ThreadPool instance = new ThreadPool();
    }

    public static ThreadPoolExecutor get() {
        return ThreadPoolTypeClass.instance.poolExecutor;
    }

    private final ThreadPoolExecutor poolExecutor;

    public ThreadPool() {
        poolExecutor = new ThreadPoolExecutor(1
                , Runtime.getRuntime().availableProcessors() - 1,
                10,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(20));
    }
}
